<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('平衡表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                              <li>
								<label>核算年度：</label>
								<select name="nd" id="nd">
									<option th:each="nd : ${ndlist}" th:text="${nd}" th:value="${nd}"> th:selected="${nd==year}"> </option>
								</select>
							</li>
                            <li >
								<label>核算期间： </label><select name="yf" id="yf">
								    <option th:each="yf : ${yflist}" th:text="${yf}" th:value="${yf}" th:selected="${yf==term}"></option>
								</select>
							</li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" shiro:hasPermission="system:trialbalance:balancecheck" onclick="balancecheck()"><i class="fa fa-refresh"></i>&nbsp;试算平衡</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
               
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:trialbalance:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/trialbalance";

        $(function() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "平衡表",
                columns: [	
                [   {
					title : '科目',
					align : 'center',
					colspan : 2
					},
                	{
					title : '期初余额',
					align : 'center',
					colspan : 2
					}, {
						title : '本期发生金额',
						align : 'center',
						colspan : 2
					}, {
						title : '期末余额',
						align : 'center',
						colspan : 2
					}
				],
                [{
                    field: 'kmdm',
                    title: '科目代码',
                },{
                    field: 'kmmc',
                    title: '科目名称',
                }, 
                {
                    field: 'beginLenderMoney',
                    title: '借方'
                },
                {
                    field: 'beginBebitMoney',
                    title: '贷方'
                },
                {
                    field: 'nowLenderMoney',
                    title: '借方'
                },{
                    field: 'nowBebitMoney',
                    title: '贷方',
                },{
                    field: 'endLenderMoney',
                    title: '借方',
                },
                {
                    field: 'endBebitMoney',
                    title: '贷方'
                }]]
            };
            $.table.init(options);
        });
        function balancecheck(){ 
        	$.modal.confirm("确认试算平衡当前所选择的会计期间？", function() {
        		$.operate.post(prefix + "/balancecheck",{nd:$("#nd").val(),yf:$("#yf").val()});
        	})
         }
    </script>
</body>
</html>